home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / misc / math / mdlgraph1.1.lha / ModuleGrapher / Source / mdlgraph.asc < prev   
Encoding:
Text File  |  1998-10-02  |  26.1 KB  |  882 lines

  1.  
  2. ;Graphing program, and fractal convergence diagram
  3. ;c1998 Stuart Reeves Module-grapher
  4. .setup
  5. ;-----------------------------------setup
  6.  
  7. version$="$VER: ModuleGrapher 1.1 (30.7.98) Stuart Reeves"
  8. ver$=Str$(1.1)
  9. title$="Module-Grapher, version "+ver$+"; "+Chr$(169)+"1998 - Stuart Reeves"
  10.  
  11. WBStartup:NoCli
  12. WBenchToFront_:WbToScreen 0
  13. mg$="ModGraph"                      ;iconpath
  14. c_path$="envarc:mdlgraph.cfg"       ;window config path
  15. p_path$="data/mdlgraph.prefs"       ;prefs path
  16. Format "-#0.00"
  17. #tag=$80080000
  18. #win_c=0:#win_fc=1:#win_g=2
  19. #win_f=3:#win_h=4:#win_p=5
  20. DefaultIDCMP $2|$4|$8|$10|$20|$40|$100|$200|$400|$40000|$80000 ;optimise later
  21.  
  22. #fld_cfg=18:#fld_prefs=5
  23.  
  24. ;...................................setup the vars
  25. .vars
  26.  
  27. NEWTYPE.convergence                 ;convergence vars
  28.   pos_x.q:iter.b                    ;x position, no. iterations
  29.   stp_x.q:stp_y                     ;size of plot
  30.   x:c                               ;dummuy vars
  31.   x_min:x_max
  32.   y_min:y_max
  33.   xl.w:yl
  34.   x_add:y_add                       ;precalc stuff
  35. End NEWTYPE
  36. USEPATH c
  37. c.convergence\x_min=-40,40,-40,40   ;TEMP VARS!
  38. c.convergence\iter=10:\c=\y_min
  39. \xl=QAbs(\x_min)+QAbs(\x_max)       ;find modulus of length
  40. \yl=QAbs(\y_min)+QAbs(\y_max)
  41.  
  42. NEWTYPE.graph
  43.   gx.q[1000]:gy[1000]               ;points to plot
  44.   pnt.w                             ;default points
  45.   a.q:b:c:pi_mul
  46.   t:x:y                             ;parameter/temp vars
  47.   x_mul.w:y_mul
  48.   x_off:y_off
  49.   ia.q:ib:ic:ip
  50. End NEWTYPE
  51. g.graph\pnt=100,2,2,2,2
  52.  
  53. NEWTYPE.flags
  54.   win_c.b:win_fc
  55.   win_g:win_f
  56.   win_h:win_p
  57.   drw_g:drw_f                       ;draw flags
  58.   u_flg:q_flg                       ;points update/quit
  59.   cg_flg:cf_flg                     ;cycle (grp+frc)
  60.   r_flg:s_flg                       ;requesters/screen
  61. End NEWTYPE
  62. f.flags\drw_g=1,0,1,0,0,0
  63.  
  64. NEWTYPE.resize                      ;gt list resizing vars
  65.   wid.w:hgt
  66.   tsize:bsize                       ;for titlebar/border size
  67.   ;gadget vars
  68.   gwid:ghgt                         ;common height/width of the gadgets
  69.   xrow_1:xrow_2
  70.   xrow_3:xrow_4
  71.   yrow_1:yrow_2                     ;gadget rows
  72.   yrow_3:yrow_4
  73.   syrow_1                           ;special yrow
  74.   ww:wh                             ;easier vars
  75. End NEWTYPE
  76. r.resize\xrow_1=0 ;dummy!
  77.  
  78. NEWTYPE.wininfo
  79.   ctrlwid.w:ctrlhgt
  80.   ctrlpos_x:ctrlpos_y
  81.   frc_ctrlwid:frc_ctrlhgt
  82.   frc_ctrlpos_x:frc_ctrlpos_y
  83.   grpwid:grphgt
  84.   grppos_x:grppos_y
  85.   frcwid:frchgt
  86.   frcpos_x:frcpos_y
  87.   hlpwid:hlphgt
  88.   hlppos_x:hlppos_y
  89.   prfwid:prfhgt
  90.   prfpos_x:prfpos_y
  91. End NEWTYPE
  92. w.wininfo\ctrlwid=400,100           ;define the unchanging vars
  93. w\frc_ctrlwid=256,130
  94. w\hlpwid=WBWidth,46,0,WBHeight-46
  95. w\prfwid=200,170
  96.  
  97. hlptxt$="Read this for help!":hlptxt_old$=hlptxt$
  98.  
  99. NEWTYPE.font
  100.   name.s:ysize.b
  101. End NEWTYPE
  102. ysize.b=11
  103. .
  104. ;-----------------------------------
  105. .includes
  106. XINCLUDE "includes/macros.i"
  107.  
  108. Macro t:g\t=g\t+(g\pi_mul*Pi)/g\pnt:End Macro ;parameter macro
  109.  
  110. XINCLUDE "includes/modules.i"
  111.  
  112. XINCLUDE "includes/reqinfo.i"
  113.  
  114. ;...................................general file ops
  115. .fileops
  116. If MakeCommodity("Module-Grapher","Module-Grapher, v"+ver$+"; Stuart Reeves","Produce graphs and fractals")=False
  117.   error{0}
  118. EndIf
  119.  
  120. If WBDepth<4
  121.   Request "Error!","Module-Grapher requires at least|16 colours to look any good!||Change your WB depth","Okay"
  122.   Exec "sys:prefs/screenmode"
  123.   End
  124. EndIf
  125.  
  126. If Exists(c_path$) AND r\ww=WBWidth AND r\wh=WBHeight
  127.   If OpenFile(0,c_path$)
  128.     !fld_cfg
  129.     For i.b=0 To #fld_cfg:Get 0,i:Next
  130.   Else error{1}
  131.   EndIf
  132. Else
  133.   USEPATH w
  134.   r\ww=WBWidth,WBHeight
  135.   f\win_c=1,0,0,0,0
  136.   \ctrlpos_x=0,16
  137.   \frc_ctrlpos_x=r\ww-w\frc_ctrlwid,16
  138.   \grpwid=300
  139.   If r\wh<300                       ;non-i/laced wb's
  140.     \grphgt=200
  141.   Else \grphgt=300
  142.   EndIf
  143.   \grppos_x=0,(r\wh-\grphgt)/1.5
  144.   \frcwid=r\ww/2,r\wh/2
  145.   \frcpos_x=r\ww-r\ww/2,(r\wh-r\wh/2)/1.5
  146.   If OpenFile(0,c_path$)
  147.     !fld_cfg
  148.     For i.b=0 To #fld_cfg:Put 0,i:Next
  149.   Else error{1}
  150.   EndIf
  151. EndIf
  152. CloseFile 0
  153.  
  154. If Exists(p_path$)
  155.   If OpenFile(1,p_path$)
  156.     !fld_prefs                      ;define the vars
  157.     For i.b=0 To #fld_prefs:Get 1,i:Next
  158.     CloseFile 1
  159.   Else error{2}
  160.   EndIf
  161. Else
  162.   Request "Error!","Can't find prefs file!||Using defaults...","Okay"
  163. ;  *f\name="helvetica.font",11
  164.   g\ia=.05:g\ib=.05:g\ic=.05:g\ip=.1
  165.   JSR prefs
  166. EndIf
  167. LoadFont 0,"helvetica.font",ysize
  168. ;If Exists("fonts:"+*f\name)
  169. ;  LoadFont 0,*f\name,*f\ysize
  170. ;Else Request "Error!","Can't find "+*f\name+"||Defaulting to Topaz.font instead","Okay"
  171. ;EndIf
  172.  
  173. If GetIconObject(mg$)
  174.   If LCase$(FindToolValue("REQUESTERS"))<>"on"
  175.     f\r_flg=0:Else f\r_flg=1
  176.   EndIf
  177.   PutIconObject(mg$):FreeIconObject ;write changes to disk/free up
  178.   Else error{3}
  179. EndIf
  180.  
  181. ;InitShape 0,44,80,3
  182. LoadShape 0,"data/logo.shp"
  183. ;DecodeShapes 0,?logo
  184.  
  185. ;...................................screen setup
  186.  
  187. ;If f\s_flg=1
  188. ;  Screen 0,0,0,640,512,7,$8000+$4,title$,1,0
  189. ;  AGARGB 0,149,149,149:AGARGB 2,255,255,255 ;grey, black, white
  190. ;  AGARGB 3,59,103,160:AGARGB 4,123,123,123:AGARGB 5,175,175,175 ;blue, grey2, grey3
  191. ;  AGARGB 6,170,144,124:AGARGB 7,255,169,151 ;pink, pink2
  192. ;  For i.b=8 To 31                   ;setup plotting colours
  193. ;    AGARGB i,rd.w,gr.w,bl.w
  194. ;    rd=rd+11:gr=gr+11:bl=bl+11
  195. ;  Next
  196. ;EndIf
  197.  
  198. ;...................................menu 0
  199. .menus
  200. #bar=$0000
  201. #check=$0001+$0008
  202. #text=$0002
  203. #disabled=$0010
  204. #itemtoggle=$0100
  205.                                                                                                                                
  206.   GTMenuTitle 0,0,"Program"
  207.   GTMenuItem 0,#text,0,0,"Help","H"
  208.   GTMenuItem 0,#text,0,1,"About","A"
  209.   GTMenuItem 0,#text,0,2,"Iconify"
  210.   GTMenuItem 0,#bar,0,3               ;separator bar
  211.   GTMenuItem 0,#text,0,4,"Quit","Q"
  212.  
  213.   GTMenuTitle 0,1,"Windows"           ;window selection
  214.   GTMenuItem 0,#check+#itemtoggle,1,0,"Graph control"
  215.   GTMenuItem 0,#check,1,1,"Fractal control"
  216.   GTMenuItem 0,#check,1,2,"Graph"
  217.   GTMenuItem 0,#check,1,3,"Fractal"
  218.   GTMenuItem 0,#check,1,4,"Help box"
  219.  
  220.   GTMenuTitle 0,#text,"Settings"
  221.   GTMenuItem 0,#text,2,0,"Preferences","P"
  222.   GTMenuItem 0,#text,2,1,"Snapshot windows"
  223. CreateMenuStrip 0
  224.  
  225. ;-----------------------------------end setup
  226. .
  227. ;-----------------------------------main loop
  228. .main
  229. JSR open
  230. If GTMenuChecked(0,1,0)=-1 AND f\win_fc=0 ;little bit to sort out menus
  231.   GTMenuState 0,1,0,Off
  232. EndIf
  233. If GTMenuChecked(0,1,1)=-1 AND f\win_c=0
  234.   GTMenuState 0,1,1,Off
  235. EndIf
  236.  
  237. Repeat
  238.  
  239.   ;***EVENTS***
  240.  
  241.   ev.l=Event:evw.l=EventWindow
  242.  
  243.   If CommodityEvent JSR chkcmd
  244.  
  245.   If AppEvent
  246.     DelAppIcon(0):JSR open
  247.   EndIf
  248.  
  249.   If ev.l=$200
  250.     Select evw.l
  251.       Case #win_c
  252.         If f\r_flg=1:!qchk          ;check to see if user wants to quit
  253.         Else f\q_flg=1
  254.         EndIf
  255.       Case #win_fc
  256.         If f\r_flg=1:!qchk          ;and again
  257.         Else f\q_flg=1
  258.         EndIf
  259.       Case #win_g
  260.         CloseWindow 2:GTSetMenuChecked 0,1,2,Off:f\win_g=0
  261.       Case #win_f
  262.         CloseWindow 3:GTSetMenuChecked 0,1,3,Off:f\win_f=0
  263.       Case #win_h
  264.         DetachGTList 2:Free GTList 2:CloseWindow 4:GTSetMenuChecked 0,1,4,Off:f\win_h=0
  265.       Case #win_p
  266.         DetachGTList 3:Free GTList 3:CloseWindow 5:f\win_p=0
  267.     End Select
  268.   EndIf
  269.  
  270.   If ev.l=$100 JSR chkmenu
  271.  
  272.   If f\win_c=1 JSR chkwin_c         ;win checks
  273.   If f\win_fc=1 JSR chkwin_fc
  274. ;  If f\win_f=1 JSR chkwin_f
  275.   If f\win_h=1 JSR chkwin_h
  276.   If f\win_p=1 JSR chkwin_p
  277.  
  278.   If ev.l=$2
  279.     Select evw
  280.       Case #win_c
  281.         DetachGTList 0:Free GTList 0
  282.         JSR gtwin_c
  283.         AttachGTList 0,#win_c
  284.       Case #win_fc
  285.         DetachGTList 1:Free GTList 1
  286.         JSR gtwin_fc
  287.         AttachGTList 1,#win_fc
  288.       Case #win_g
  289.         Use Window 2
  290.         w\grpwid=WindowWidth:w\grphgt=WindowHeight ;get new params, and update muls.
  291.         JSR updcyc_grp
  292.         Use Window 2
  293.         WBox 0,0,w\grpwid,w\grphgt,0
  294.         f\drw_g=1
  295.       Case #win_p                   ;clear the window and resize gadgets
  296.         DetachGTList 3:Free GTList 3
  297.         JSR gtwin_p
  298.         AttachGTList 3,5
  299.     End Select
  300.   EndIf
  301.  
  302.   ;***END EVENTS***
  303.  
  304.   ;+++++++++++++++++++++++++++++++++begin ctrl gadget hit
  305.  
  306.     If f\drw_g=1 AND f\win_g=1      ;if exists and hasn't finished
  307.       JSR calcgrp                   ;first calculate the graph points
  308.       draw
  309.       f\u_flg=GTStatus(0,9)
  310.       If f\win_g=1
  311.         JSR drwgrp                  ;and draw the graph
  312.       EndIf
  313.     EndIf
  314.  
  315.   ;+++++++++++++++++++++++++++++++++end ctrl hit
  316.  
  317.   ;+++++++++++++++++++++++++++++++++begin frc gadget hit
  318.  
  319.     If f\drw_f=1 AND f\win_f=1      ;if exists, and hasn't finished
  320.       JSR drwfrc
  321.     EndIf
  322.  
  323.   ;+++++++++++++++++++++++++++++++++end frc hit
  324.  
  325.   If f\drw_f=0 OR f\drw_g=0 VWait   ;for multitasking purposes
  326.   f\drw_g=0                         ;to stop it continually drawing
  327.  
  328. Until f\q_flg=1 OR RawStatus($45)
  329.  
  330. ;-----------------------------------end main loop
  331.  
  332. .quit
  333.   If f\win_c=1 CloseWindow #win_c:If f\win_fc=1 CloseWindow #win_fc
  334.   If f\win_g=1 CloseWindow #win_g:If f\win_h=1 CloseWindow #win_h
  335.   If f\win_p=1 CloseWindow #win_p
  336.   If f\r_flg=1 Request "Be nice to programmers!",req_end$,"Okay"
  337.   End
  338. .
  339. ;===================================subroutines
  340.  
  341. ;...................................stuff to startup/close prog
  342.  
  343. .iconify
  344.   If AddAppIcon(0,"Module-Grapher",mg$)
  345.     JSR close
  346.   Else
  347.     Request "Error!","Could not iconify Module-Grapher...","Okay"
  348.   EndIf
  349. RTS
  350.  
  351. .open                               ;open the prog!
  352.   If f\win_c=1 !ctrlwin:If f\win_fc=1 !frc_ctrlwin
  353.   If f\win_g=1 !grpwin:If f\win_f=1 !frcwin
  354.   If f\win_h=1 !hlpwin:If f\win_p=1 !prfwin
  355. RTS
  356.  
  357. .close
  358.   If f\win_c=1:DetachGTList 0:Free GTList 0:CloseWindow #win_c:EndIf
  359.   If f\win_fc=1:DetachGTList 1:Free GTList 1:CloseWindow #win_fc:EndIf
  360.   If f\win_g=1 CloseWindow 2
  361.   If f\win_f=1 CloseWindow 3
  362.   If f\win_h=1:DetachGTList 2:Free GTList 2:CloseWindow #win_h:EndIf
  363.   If f\win_p=1:DetachGTList 3:Free GTList 3:CloseWindow #win_p:EndIf
  364. RTS
  365.  
  366. ;...................................graph + frc stuff
  367.  
  368. .calcgrp
  369.   USEPATH g
  370.   Use Window #win_c
  371.   If \a=>99.95 \a=99.95:If \a<=-99.95 \a=-99.95
  372.   If \b=>99.95 \b=99.95:If \b<=-99.95 \b=-99.95
  373.   If \c=>99.95 \c=99.95:If \c<=-99.95 \c=-99.95
  374.   If \pi_mul=>99.9 \pi_mul=99.9:If \pi_mul<=-99.9 \pi_mul=-99.9
  375.   GTSetString 0,1,Str$(\a)          ;update vars
  376.   GTSetString 0,4,Str$(\b)
  377.   GTSetString 0,7,Str$(\c)
  378.   GTSetString 0,11,Str$(\pi_mul)
  379.   \t=0                              ;reset the parameter
  380.   For n.w=0 To \pnt                 ;calculate points
  381.     Select f\cg_flg
  382.       Case 0:!t:!grp_0
  383.       Case 1:!t:!grp_1
  384.       Case 2:!t:!grp_2
  385. ;      Case 3:!t:!grp_3
  386. ;      Case 4:!t:!grp_4
  387.       Case 5:!t:!grp_5
  388. ;      Case 6:!t:!grp_6
  389.       Case 7:!t:!grp_7
  390.     End Select
  391.     \gx[n]=(\x+1)*\x_mul+\x_off
  392.     \gy[n]=(\y+1)*\y_mul+\y_off
  393.     If n=\pnt f\drw_g=0
  394.   Next
  395. RTS
  396.  
  397. .drwgrp
  398.   USEPATH g
  399.   Use Window #win_g
  400.   WBox 0,0,w\grpwid,w\grphgt,0
  401.   For n.w=0 To \pnt
  402.     If GTStatus(0,9)=0
  403.       WPlot \gx[n],\gy[n],1
  404.     Else If n>1 WLine \gx[n-1],\gy[n-1],\gx[n],\gy[n],2
  405.     EndIf
  406.     If n=\pnt f\drw_g=0
  407.   Next
  408. RTS
  409.  
  410. .drwfrc
  411.   USEPATH c
  412.   Use Window #win_f
  413.   WTitle "Fractal - "+UStr$(InnerWidth)+"x"+UStr$(InnerHeight),"Fractal convergence window"
  414.   \stp_x=InnerWidth/\xl,InnerHeight/\yl ;update winsize values
  415.   \x_add=QAbs(\x_min)*\stp_x:\y_add=QAbs(\y_min)*\stp_y ;pre-calc!
  416.   Repeat
  417.     For \pos_x=\x_min To \x_max Step (1/\stp_x) ;increase x
  418.       \x=\pos_x                     ;start value for pixel test
  419.       For i.b=1 To \iter            ;pixel iteration
  420.         Select f\cf_flg
  421.           Case 0:!frc_0
  422.           Case 1:!frc_1
  423.           Case 2:!frc_2
  424.           Case 3:!frc_3
  425.           Case 4:!frc_4
  426.           Case 5:!frc_5
  427.           Case 6:!frc_6
  428.         End Select
  429.       Next
  430.       WPlot \pos_x*\stp_x+\x_add,\c*\stp_y+\y_add,QLimit(\x,-128,128)
  431.     Next
  432.     \c=\c+1/\stp_y                  ;increase y (constant)
  433.   Until \c>\y_max OR GTStatus(1,3)=1
  434.   GTMenuState 0,1,3,On:f\drw_f=0
  435.   \pos_x=0:\c=\x_min
  436.   hlptxt$="Drawing process has finished..."
  437. RTS
  438.  
  439. ;...................................prefs stuff
  440.  
  441. .winsnap                            ;find all win coords
  442.   USEPATH w
  443.   If f\win_c=1
  444.     Use Window #win_c
  445.     \ctrlpos_x=WindowX-r\bsize,WindowY-r\tsize
  446.   EndIf
  447.   If f\win_fc=1
  448.     Use Window #win_fc
  449.     \frc_ctrlpos_x=WindowX-r\bsize,WindowY-r\tsize
  450.   EndIf
  451.   If f\win_g=1
  452.     Use Window #win_g
  453.     \grppos_x=WindowX-r\bsize,WindowY-r\tsize
  454.     \grpwid=WindowWidth,WindowHeight
  455.   EndIf
  456.   If f\win_f=1
  457.     Use Window #win_f
  458.     \frcpos_x=WindowX-r\bsize,WindowY-r\tsize
  459.     \frcwid=WindowWidth,WindowHeight
  460.   EndIf
  461.   If OpenFile(0,c_path$)
  462.     !fld_cfg
  463.     For i.b=0 To #fld_cfg:Put 0,i:Next
  464.     CloseFile 0
  465.   Else error{1}
  466.   EndIf
  467. RTS
  468.  
  469. .prefs
  470.   If OpenFile(1,p_path$)
  471.     !fld_prefs
  472.     For i.b=0 To #fld_prefs:Put 1,i:Next
  473.     CloseFile 1
  474.   Else error{2}
  475.   EndIf
  476. RTS
  477.  
  478. ;...................................gtlist 0-win_c
  479.  
  480. .gtwin_c
  481.   Use Window #win_c:r\wid=InnerWidth,InnerHeight ;font sensitivity
  482.   WCls                              ;get rid of any excess gumpfff
  483.   WBlit 0,0,r\hgt*.5-40             ;plot that logo!
  484.   r\gwid=ysize*.75,ysize+6
  485.   r\xrow_1=-r\bsize+r\wid*.15+40,-r\bsize+r\wid*.4+32,-r\bsize+r\wid*.65+24,-r\bsize+r\wid*.9+10
  486.   r\yrow_1=-r\tsize+r\hgt*.35-r\ghgt/2,-r\tsize+r\hgt*.75-r\ghgt/2
  487.  
  488.   WLine 44+(r\xrow_1-r\gwid-35-44)/2,r\yrow_1+r\ghgt,44+(r\xrow_1-r\gwid-35-44)/2,r\yrow_2+6+r\ghgt,1
  489.   WLine 45+(r\xrow_1-r\gwid-35-44)/2,r\yrow_1+r\ghgt,45+(r\xrow_1-r\gwid-35-44)/2,r\yrow_2+6+r\ghgt,2
  490.   ;constant a
  491.   GTButton 0,0,r\xrow_1-r\gwid-35,r\yrow_1,r\gwid+10,r\ghgt,"<",$10
  492.   GTString 0,1,r\xrow_1+r\gwid+10-r\gwid-35,r\yrow_1,50,r\ghgt,"A",$4,5,Str$(g\a)
  493.   GTButton 0,2,r\xrow_1+r\gwid+60-r\gwid-35,r\yrow_1,r\gwid+10,r\ghgt,">",$10
  494.   ;constant b
  495.   GTButton 0,3,r\xrow_2-r\gwid-35,r\yrow_1,r\gwid+10,r\ghgt,"<",$10
  496.   GTString 0,4,r\xrow_2+r\gwid+10-r\gwid-35,r\yrow_1,50,r\ghgt,"B",$4,5,Str$(g\b)
  497.   GTButton 0,5,r\xrow_2+r\gwid+60-r\gwid-35,r\yrow_1,r\gwid+10,r\ghgt,">",$10
  498.   ;constant c
  499.   GTButton 0,6,r\xrow_3-r\gwid-35,r\yrow_1,r\gwid+10,r\ghgt,"<",$10
  500.   GTString 0,7,r\xrow_3+r\gwid+10-r\gwid-35,r\yrow_1,50,r\ghgt,"C",$4,5,Str$(g\c)
  501.   GTButton 0,8,r\xrow_3+r\gwid+60-r\gwid-35,r\yrow_1,r\gwid+10,r\ghgt,">",$10
  502.  
  503.   ;GTTags #tag+68,1
  504.   GTCheckBox 0,9,r\xrow_4-r\gwid*1.5,r\yrow_1,0,0,"Line/Dot",$4+$100
  505.   ;constant n*Pi
  506.   GTButton 0,10,r\xrow_1-r\gwid-35,r\yrow_2,r\gwid+10,r\ghgt,"<",$10
  507.   GTString 0,11,r\xrow_1+r\gwid+10-r\gwid-35,r\yrow_2,50,r\ghgt,"nxPi",$4,5,Str$(g\pi_mul)
  508.   GTButton 0,12,r\xrow_1+r\gwid+60-r\gwid-35,r\yrow_2,r\gwid+10,r\ghgt,">",$10
  509.  
  510.   GTButton 0,13,r\xrow_2-r\gwid*3-5,r\yrow_2,r\gwid*6+10,r\ghgt,"Redraw",$10
  511.  
  512.   GTTags #tag+15,0                   ;set the first item
  513.   GTCycle 0,14,r\xrow_3-r\gwid*5-5,r\yrow_2,r\gwid*10+10,r\ghgt,"Module",$4,grpmdl$,0
  514.  
  515.   GTInteger 0,15,r\xrow_4-21,r\yrow_2,42,r\ghgt,"Points",$4,100
  516. RTS
  517.  
  518. ;...................................gtlist 1-win_fc
  519.  
  520. .gtwin_fc
  521.   Use Window #win_fc:r\wid=InnerWidth,InnerHeight
  522.   WCls
  523.   r\gwid=ysize*.75,ysize+6
  524.   r\xrow_1=-r\bsize+r\wid*.15,-r\bsize+r\wid*.4,-r\bsize+r\wid*.75
  525.   r\yrow_1=-r\tsize+r\hgt*.25-r\ghgt/2,-r\tsize+r\hgt*.55-r\ghgt/2,-r\tsize+r\hgt*.85-r\ghgt/2
  526.  
  527.   GTString 1,0,r\xrow_1-25,r\yrow_1,50,r\ghgt,"X-min",$4,6,Str$(c\x_min)
  528.  
  529.   GTString 1,1,r\xrow_2-25,r\yrow_1,50,r\ghgt,"X-max",$4,6,Str$(c\x_max)
  530.  
  531.   GTButton 1,2,r\xrow_3-r\gwid*5-10,r\yrow_1,r\gwid*5+10,r\ghgt,"Start",$10
  532.   GTButton 1,3,r\xrow_3+r\gwid*5-10-r\gwid*5+10,r\yrow_1,r\gwid*5+10,r\ghgt,"Stop",$10
  533.  
  534.   GTInteger 1,8,r\xrow_3-r\gwid*2.5-24,r\yrow_3,38,r\ghgt,"Iterations",$4,c\iter
  535.   GTButton 1,4,r\xrow_3-r\gwid*2.5+14,r\yrow_3,r\gwid*5+10,r\ghgt,"Clear",$10
  536.  
  537.   GTString 1,5,r\xrow_1-25,r\yrow_2,50,r\ghgt,"Y-min",$4,6,Str$(c\y_min)
  538.  
  539.   GTString 1,6,r\xrow_2-25,r\yrow_2,50,r\ghgt,"Y-max",$4,6,Str$(c\y_max)
  540.  
  541.   GTTags #tag+15,0
  542.   GTCycle 1,7,r\xrow_3-r\gwid*6-5,r\yrow_2,r\gwid*12+10,r\ghgt,"Formula",$4,frcmdl$,0
  543. RTS
  544.  
  545. ;...................................gtlist 2-win_h
  546.  
  547. .gtwin_h
  548.   Use Window #win_h:r\wid=InnerWidth,InnerHeight
  549.   WCls
  550.   GTText 2,0,0,-r\tsize+r\hgt*.5-r\ghgt/2,r\ww-12,r\ghgt,"",$4,hlptxt$ ;the help box!+4 pizel gap at top
  551. RTS
  552.  
  553. ;...................................gtlist 3-win_p
  554.  
  555. .gtwin_p
  556.   Use Window #win_p:r\wid=InnerWidth,InnerHeight
  557.   WCls
  558.   r\xrow_1=-r\bsize+r\wid*.25,-r\bsize+r\wid*.5,-r\bsize+r\wid*.75
  559.   r\yrow_1=-r\tsize+r\hgt*.2-r\ghgt/2,-r\tsize+r\hgt*.45-r\ghgt/2,-r\tsize+r\hgt*.7-r\ghgt/2,-r\tsize+r\hgt*.9-r\ghgt/2
  560.   r\syrow_1=r\yrow_4/2+r\ghgt*1.25+r\yrow_3/2
  561.  
  562.   WLine r\xrow_1-6,r\syrow_1,r\xrow_3+6,r\syrow_1,2
  563.   WLine r\xrow_1-6,r\syrow_1-1,r\xrow_3+6,r\syrow_1-1,1
  564.  
  565.   GTButton 3,0,r\xrow_1-r\gwid*2-5,r\yrow_4,r\gwid*4+10,r\ghgt,"Save",$10
  566.   GTButton 3,1,r\xrow_2-r\gwid*2-5,r\yrow_4,r\gwid*3+10,r\ghgt,"Use",$10
  567.   GTButton 3,2,r\xrow_3-r\gwid*3-5,r\yrow_4,r\gwid*6+10,r\ghgt,"Cancel",$10
  568.  
  569.   GTString 3,3,r\xrow_1-25,r\yrow_1,50,r\ghgt,"A increment",$4,5,Str$(g\ia)
  570.  
  571.   GTString 3,4,r\xrow_3-25,r\yrow_1,50,r\ghgt,"B increment",$4,5,Str$(g\ib)
  572.  
  573.   GTString 3,5,r\xrow_1-25,r\yrow_2,50,r\ghgt,"C increment",$4,5,Str$(g\ic)
  574.  
  575.   GTString 3,6,r\xrow_3-25,r\yrow_2,50,r\ghgt,"Pi increment",$4,5,Str$(g\ip)
  576.  
  577.   GTButton 3,7,r\xrow_1-25,r\yrow_3-4,50,r\ghgt,"Font",$10
  578.  
  579.   If f\r_flg=1 req_flg.l=$100:Else req_flg=$0 ;make chk box on or off
  580.   GTCheckBox 3,8,r\xrow_3-r\gwid*1.5,r\yrow_3,0,0,"Requesters",$4+req_flg
  581. RTS
  582.  
  583. ;...................................checks
  584.  
  585. .updcyc_grp
  586.   USEPATH g
  587.   Use Window #win_c
  588.   evc.l=EventCode
  589.   Select evc.l
  590.     Case 0
  591.       !grp_0vars:!eBdC
  592.       hlptxt$=grp_0txt$:f\cg_flg=0:f\drw_g=1
  593.     Case 1
  594.       !grp_1vars:!eBdC
  595.       hlptxt$=grp_1txt$:f\cg_flg=1:f\drw_g=1
  596.     Case 2
  597.       !grp_2vars:!eBeC
  598.       hlptxt$=grp_2txt$:f\cg_flg=2:f\drw_g=1
  599. ;    Case 3
  600. ;      !grp_3vars:!dBdC
  601. ;      hlptxt$=grp_3txt$:f\cg_flg=3:f\drw_g=1
  602. ;    Case 4
  603. ;      !grp_4vars:!dBdC
  604. ;      hlptxt$=grp_4txt$:f\cg_flg=4:f\drw_g=1
  605.     Case 5
  606.       !grp_5vars:!dBdC
  607.       hlptxt$=grp_5txt$:f\cg_flg=5:f\drw_g=1
  608. ;    Case 6
  609. ;      !grp_6vars:!dBdC
  610. ;      hlptxt$=grp_6txt$:f\cg_flg=6:f\drw_g=1
  611.     Case 7
  612.       !grp_7vars:!eBdC
  613.       hlptxt$=grp_7txt$:f\cg_flg=7:f\drw_g=1
  614.   End Select
  615. RTS
  616.  
  617. .updcyc_frc
  618.   USEPATH c
  619.   Use Window #win_fc
  620.   evc.l=EventCode
  621.   Select evc.l
  622.     Case 0
  623.       f\cf_flg=0:!frc_0vars
  624.       hlptxt$="Formula: "+frc_0txt$+"; with "+UStr$(\iter)+" iterations per pixel"
  625.     Case 1
  626.       f\cf_flg=1:!frc_1vars
  627.       hlptxt$="Formula: "+frc_1txt$+"; with "+UStr$(\iter)+" iterations per pixel"
  628.     Case 2
  629.       f\cf_flg=2!frc_2vars
  630.       hlptxt$="Formula: "+frc_2txt$+"; with "+UStr$(\iter)+" iterations per pixel"
  631.     Case 3
  632.       f\cf_flg=3:!frc_3vars
  633.       hlptxt$="Formula: "+frc_3txt$+"; with "+UStr$(\iter)+" iterations per pixel"
  634.     Case 4
  635.       f\cf_flg=4:!frc_4vars
  636.       hlptxt$="Formula: "+frc_4txt$+"; with "+UStr$(\iter)+" iterations per pixel"
  637.     Case 5
  638.       f\cf_flg=5:!frc_5vars
  639.       hlptxt$="Formula: "+frc_5txt$+"; with "+UStr$(\iter)+" iterations per pixel"
  640.     Case 6
  641.       f\cf_flg=6:!frc_6vars
  642.       hlptxt$="Formula: "+frc_6txt$+"; with "+UStr$(\iter)+" iterations per pixel"
  643.   End Select
  644.   GTSetString 1,0,Str$(\x_min)
  645.   GTSetString 1,1,Str$(\x_max)
  646.   GTSetString 1,5,Str$(\y_min)
  647.   GTSetString 1,6,Str$(\y_max)
  648. RTS
  649.  
  650. .chkmenu
  651.   Select MenuHit
  652.     Case 0                          ;menu 0
  653.       If ItemHit=0 Exec "sys:utilities/multiview docs/modgraph.guide" ;online help!
  654.       If ItemHit=1
  655.         Request "About this program",req_ab$,"Okay"
  656.         FlushEvents
  657.       EndIf
  658.       If ItemHit=2 JSR iconify
  659.       If ItemHit=4 AND f\r_flg=1:!qchk:EndIf
  660.       If ItemHit=4 AND f\r_flg=0 JMP quit
  661.     Case 1
  662.       If GTMenuChecked(0,1,0)=0 AND f\win_c=1 ;check for ctrl win
  663.         DetachGTList 0:Free GTList 0:CloseWindow 0:f\win_c=0
  664.         GTMenuState 0,1,1,Off       ;make sure other is unable to close
  665.       Else If GTMenuChecked(0,1,0)=-1 AND f\win_c=0
  666.         !ctrlwin
  667.         GTMenuState 0,1,1,On:EndIf
  668.       EndIf
  669.       If GTMenuChecked(0,1,1)=0 AND f\win_fc=1 ;check for frc ctrl win
  670.         DetachGTList 1:Free GTList 1:CloseWindow 1:f\win_fc=0
  671.         GTMenuState 0,1,0,Off
  672.       Else If GTMenuChecked(0,1,1)=-1 AND f\win_fc=0
  673.         !frc_ctrlwin
  674.         GTMenuState 0,1,0,On:EndIf
  675.       EndIf
  676.       If GTMenuChecked(0,1,2)=0 AND f\win_g=1 ;check for graph win
  677.         CloseWindow 2:f\win_g=0
  678.       Else If GTMenuChecked(0,1,2)=-1 AND f\win_g=0
  679.         !grpwin:f\drw_g=1:EndIf
  680.       EndIf
  681.       If GTMenuChecked(0,1,3)=0 AND f\win_f=1 ;check for fractal win
  682.         CloseWindow 3:f\win_f=0
  683.       Else If GTMenuChecked(0,1,3)=-1 AND f\win_f=0
  684.         !frcwin
  685.         USEPATH c
  686.         \pos_x=0:\c=\x_min:EndIf    ;reset the drawing vars
  687.       EndIf
  688.       If GTMenuChecked(0,1,4)=0 AND f\win_h=1 ;check for help win
  689.         DetachGTList 2:Free GTList 2:CloseWindow 4:f\win_h=0
  690.       Else If GTMenuChecked(0,1,4)=-1 AND f\win_h=0
  691.         !hlpwin
  692.         GTSetString 2,0,hlptxt$:EndIf
  693.       EndIf
  694.     Case 2
  695.       If ItemHit=0 AND f\win_p=0
  696.         !prfwin
  697.       Else Activate 5
  698.       EndIf
  699.       If ItemHit=1 JSR winsnap
  700.   End Select
  701. RTS
  702.  
  703. .chkwin_c
  704.   USEPATH g
  705.   Use Window #win_c
  706.   If GTGetString(0,1)<>Str$(\a)     ;find+limit vars
  707.     \a=Val(GTGetString(0,1))
  708.     If \a=>99.95 \a=99.95:If \a<=-99.95 \a=-99.95
  709.   EndIf
  710.   If GTGetString(0,4)<>Str$(\b)
  711.     \b=Val(GTGetString(0,4))
  712.     If \b=>99.95 \b=99.95:If \b<=-99.95 \b=-99.95
  713.   EndIf
  714.   If GTGetString(0,7)<>Str$(\c)
  715.     \c=Val(GTGetString(0,7))
  716.     If \c=>99.95 \c=99.95:If \c<=-99.95 \c=-99.95
  717.   EndIf
  718.   If GTGetString(0,11)<>Str$(\pi_mul)
  719.     \pi_mul=Val(GTGetString(0,11))
  720.     If \pi_mul=>99.9 \pi_mul=99.9:If \pi_mul<=-99.9 \pi_mul=-99.9
  721.   EndIf
  722.   If GTStatus(0,13)=1               ;redraw button
  723.     f\drw_g=1
  724.     hlptxt$="Graph window redrawn..."
  725.   EndIf
  726.   If GTStatus(0,0)=1:\a=\a-\ia:f\drw_g=1:EndIf ;check the gadgets to change vars a+b
  727.   If GTStatus(0,2)=1:\a=\a+\ia:f\drw_g=1:EndIf
  728.   If GTStatus(0,3)=1:\b=\b-\ib:f\drw_g=1:EndIf
  729.   If GTStatus(0,5)=1:\b=\b+\ib:f\drw_g=1:EndIf
  730.   If GTStatus(0,6)=1:\c=\c-\ic:f\drw_g=1:EndIf
  731.   If GTStatus(0,8)=1:\c=\c+\ic:f\drw_g=1:EndIf
  732.   If GTStatus(0,10)=1:\pi_mul=\pi_mul-\ip:f\drw_g=1:EndIf ;and pi_mul*Pi
  733.   If GTStatus(0,12)=1:\pi_mul=\pi_mul+\ip:f\drw_g=1:EndIf
  734.   If GTStatus(0,9)<>f\u_flg JMP draw ;update the screen if changing dots or lines
  735.   If GadgetHit=14 AND evw.l=0 JSR updcyc_grp ;subr. to update cycle gadget+update mul. vars
  736.   If GTGetInteger(0,15)<>\pnt       ;find the no. points put in by user
  737.     \pnt=GTGetInteger(0,15)
  738.     If \pnt>1000:\pnt=1000:GTSetInteger 0,15,1000:EndIf ;limit to <1000
  739.     If \pnt<1:\pnt=1:GTSetInteger 0,15,1:EndIf ;and to >0
  740.     f\drw_g=1                       ;update after points are inputted
  741.     hlptxt$="The number of points used to draw the graph display."
  742.   EndIf
  743. RTS
  744.  
  745. .chkwin_fc
  746.   USEPATH c
  747.   Use Window #win_fc
  748.   If GTGetString(1,0)<>Str$(\x_min)
  749.     \x_min=Val(GTGetString(1,0))
  750.   EndIf
  751.   If GTGetString(1,1)<>Str$(\x_max)
  752.     \x_max=Val(GTGetString(1,1))
  753.   EndIf
  754.   If GTGetString(1,5)<>Str$(\y_min)
  755.     \y_min=Val(GTGetString(1,5))
  756.   EndIf
  757.   If GTGetString(1,6)<>Str$(\y_max)
  758.     \y_max=Val(GTGetString(1,6))
  759.   EndIf
  760.   If f\win_f=1                      ;make sure it exists
  761.     If GTStatus(1,2)=1
  762.       f\drw_f=1:GTMenuState 0,1,3,Off
  763.       \xl=QAbs(\x_min)+QAbs(\x_max)
  764.       \yl=QAbs(\y_min)+QAbs(\y_max)
  765.       hlptxt$="You have started to draw a convergence diagram where `c' is the y-value"
  766.     EndIf
  767.     If GTStatus(1,3)=1
  768.       f\drw_f=0:GTMenuState 0,1,3,On
  769.       hlptxt$="Halted drawing process..."
  770.     EndIf
  771.     If GTStatus(1,4)=1              ;clear
  772.       Use Window 3
  773.       f\drw_f=0
  774.       \pos_x=0:\c=\x_min
  775.       WBox 0,0,InnerWidth,InnerHeight,0
  776.       hlptxt$="Cleared the drawing window..."
  777.     EndIf
  778.   EndIf
  779.   If GadgetHit=7 AND evw.l=1
  780.     \pos_x=0:\c=\x_min:f\drw_f=0
  781.     JSR updcyc_frc
  782.   EndIf
  783.   If GTGetInteger(1,8)<>\iter       ;find no. iterations
  784.     \iter=GTGetInteger(1,8)
  785.     If \iter>128 \iter=128
  786.     GTSetInteger 1,8,\iter
  787.     hlptxt$="This changes the number of iterations per pixel; so bigger values will take longer, and smaller ones, shorter."
  788.   EndIf
  789. RTS
  790.  
  791. ;.chkwin_f
  792. ;  USEPATH c
  793. ;  Use Window #win_f                 ;check size of frc win
  794. ;  If ev.l=$8 AND evw.l=3
  795. ;    Use Window 3
  796. ;    mx_min.w=(WMouseX-QAbs(\x_min)*\stp_x)/\stp_x-5
  797. ;    mx_max.w=(WMouseX-QAbs(\x_min)*\stp_x)/\stp_x+5
  798. ;    my_min.w=(WMouseY-QAbs(\y_min)*\stp_y)/\stp_y-5
  799. ;    my_max.w=(WMouseY-QAbs(\y_min)*\stp_y)/\stp_y+5
  800. ;    \x_min=mx_min,mx_max,my_min,my_max ;then make a range
  801. ;    \pos_x=0:\c=\x_min
  802. ;    GTSetString 1,0,Str$(\x_min):GTSetString 1,1,Str$(\x_max)
  803. ;    GTSetString 1,5,Str$(\y_min):GTSetString 1,6,Str$(\y_max)
  804. ;  EndIf
  805. ;RTS
  806.  
  807. .chkwin_h
  808.   Use Window #win_h
  809.   If ev.l=$40000                    ;choose the txt displayed
  810.     Select evw
  811.       Case #win_c
  812.         hlptxt$="This window controls the value of the constants in the equations."
  813.       Case #win_fc
  814.         hlptxt$="This window controls the fractal drawing window, and lets you alter the plot ranges."
  815.       Case #win_g
  816.         hlptxt$="This window displays the current module's graph function, depending on the constants."
  817.       Case #win_f
  818.         hlptxt$="This window displays a convergence diagram of the current function, where the colour shows speed "
  819.         hlptxt$=hlptxt$+"of convergence"
  820.       Case #win_h
  821.         hlptxt$="This is the help box and is supposed to give you 'helpful' comments..."
  822.       Case #win_p
  823.         hlptxt$="This window controls the preferences for Module-Grapher"
  824.     End Select
  825.   EndIf
  826.   If hlptxt$<>hlptxt_old$ AND f\win_h=1
  827.     GTSetString 2,0,hlptxt$
  828.     hlptxt_old$=hlptxt$
  829.   EndIf
  830. RTS
  831.  
  832. .chkwin_p
  833.   Use Window #win_p
  834.   If GTStatus(3,0)=1 OR GTStatus(3,1)=1 ;save/use
  835.     g\ia=Val(GTGetString(3,3)):g\ib=Val(GTGetString(3,4))
  836.     g\ic=Val(GTGetString(3,5)):g\ip=Val(GTGetString(3,6))
  837.     If GTStatus(3,8)<>f\r_flg AND GTStatus(3,0)=1
  838.       f\r_flg=GTStatus(3,8)
  839.       GetIconObject(mg$)
  840.       If LCase$(FindToolValue("REQUESTERS"))<>"on"
  841.         evt=SetToolValue("REQUESTERS","ON")
  842.         Else:evt=SetToolValue("REQUESTERS","OFF")
  843.         EndIf
  844.       PutIconObject(mg$):FreeIconObject
  845.     EndIf
  846.     If GTStatus(3,0)=1 JSR prefs
  847.     DetachGTList 3:CloseWindow 5:f\win_p=0
  848.   EndIf
  849.   If GTStatus(3,2)=1                  ;cancel
  850.     DetachGTList 3:CloseWindow 5:f\win_p=0
  851.   EndIf
  852.   If GTStatus(3,7)=1
  853.     *f=ASLFontRequest(0)
  854.     Request "Watch it!","Not a fully implemented feature... :))","Okay, I`ll just have to do without it"
  855. ;    If *f
  856. ;      LoadFont 0,*f\name,*f\ysize
  857. ;      ysize=*f\ysize
  858. ;      JSR close:JSR open            ;refresh the display
  859. ;    EndIf
  860.   EndIf
  861. RTS
  862.  
  863. .chkcmd
  864.   evcmd.l=ExchangeMessage
  865.   Select evcmd
  866.     Case CxKill
  867.       JMP quit
  868.     Case CxDisAppear
  869.       JSR iconify
  870.     Case CxAppear
  871.       JSR open:DelAppIcon(0)
  872. ;    Case CxDisable
  873. ;      Repeat
  874. ;        VWait
  875. ;      Until ExchangeMessage=CxEnable
  876.   End Select
  877. RTS
  878.  
  879. logo:
  880. ;  IncBin "data/logo.shp"
  881.  
  882.